﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>唻设计</title>
 <link rel="stylesheet" href="css/lipe.css"/>
  <link rel="stylesheet" href="css/page2.css"/>
 <link href="http://cdn.staticfile.org/twitter-bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" media="all"/>
<script type="text/javascript" src="${ctx}/resources/plugins/jquery-easyui-1.4.3/jquery.min.js"></script>
	<script src="${ctx}/js/ajaxfileupload.js"></script>
	<script src="${ctx}/js/jquery.dialog.js"></script>
	  <script src="${ctx}/js/jqPaginator.js"></script>
	<script type="text/javascript">
	 var leftsize = (window.screen.availWidth - 980 )/2 ;
	 var searchDig = null; 
	 var userid = '';
	 var token = '';
	 var username = '';
	 
	 String.prototype.getQueryString = function(name)   
	 {   
	    var reg = new RegExp("(^|&|\\?)"+ name +"=([^&]*)(&|$)"), r;   
	    if ( r=this.match(reg) ) return unescape(r[2]);   
	    return null;   
	 }  
	    
	 $(document).ready(function(){
		 var url=window.location.href;
		 userid = url.getQueryString("userid");
		 token = url.getQueryString("token");  
		 username = url.getQueryString("username");  
		 
		  $(window).unload(function(){
		           opener.designWindowClosed();    
		  });
		  
		  searchDig =  $.dialog({
			 	html: $("#searchPanel").html()
		   });
		  $(".dialog-box").css("left",leftsize+"px");
		  $("#searchPanel").remove();
		  
		  $("#pageiter").jqPaginator({
	            totalPages: 100,
	            visiblePages: 10,
	            currentPage: 1,
	            first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
	            prev: '<li class="prev"><a href="javascript:void(0);"><i class="arrow arrow2"><\/i>上一页<\/a><\/li>',
	            next: '<li class="next"><a href="javascript:void(0);">下一页<i class="arrow arrow3"><\/i><\/a><\/li>',
	            last: '<li class="last"><a href="javascript:void(0);">末页<\/a><\/li>',
	            page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
	            onPageChange: function (n) {
	            	queryPage(n) ;
	            }
	        });
		  
		  
		  $("#uFrame").css("height",window.screen.availHeight);
		      closeUploadPanel();
		     
		      
	      $(document).on("click",  ".btn-search" ,function(e){
	    	   queryPage(1);
	       });
	      
	      $(document).on("click",  "#searchList li" ,function(e){
	    	    var src = $(this).find("img").attr("src") ; 
	    	    loadHourse(src);
	       });

		 });
	 
	 
    function queryPage(page){
       var keyword = $("#keyword").val(); 
  	   $.ajax({
  		   url: '${ctx}/customer/queryHouseModel.do',
  		   data:{keyword:keyword ,page:page ,limit: 10},
  		   success:function(e){
  			   //Title;//户型名称
//     private String PicUrl;/
  			    var img = null;
  			    $("#searchList").empty();
  			    $.each(e.rows, function(index,el){
  			    	console.log(el) ;
  			    	var img =  el.picUrl ;
  			    	var title = el.title ; 
  	  			    $("#searchList").append("<li style=\"width: 160px;\"><img src=\"http://114.55.37.217:8003/resource/"+ img + "\"  style=\"width:160px;height: 160px;\"><div class=\"mmax hide\">"+ title +"</div></li>")
  			    });
  			    $("#pageiter").jqPaginator('option', {
  		            totalPages:  e.totalpage,
  		            visiblePages: 10,
  		            currentPage: 1
  		         });
  		   },error:function(e){
  			   
  		   }
  	   });
    } 

	function uploadImage(id){
		$.ajaxFileUpload({
			url: '${ctx}/file/qiniuFileUpload.do',
			type: 'post',
			secureuri: false,             //一般设置为false
			fileElementId: id,    // 上传文件的id、name属性名
			dataType: 'json',             //返回值类型，一般设置为json、application/json
			success: function(res, status){
				if(res.code == "0000"){
					//var picUrl = 'http://7xl6wk.com1.z0.glb.clouddn.com/'+ res.data+"?imageView2/2/w/200/h/120";
					var picUrl = 'http://7xl6wk.com1.z0.glb.clouddn.com/'+ res.data;
 					$("#image_preview").attr("src",picUrl);
					unityFrame.window.imageUploaded(picUrl);
					closeUploadPanel();
				}else{
					alert(res.msg) ;
				}
			},
			error: function(data, status, e){
			}
		});
	}

	//关闭上传对话框
	function closeUploadPanel(){
		$("#uploadPanel").hide();
	}
	
	function closeUploadPanelAndShowUnity(){
		$("#uploadPanel").hide();
		unityFrame.window.showUnity3d();
	}
	//打开上传对话框
	function showUploadPanel(){
		$("#uploadPanel").show();
	}
	//登陆之后传入USERID
	function getUserId(){
		var json='{"UserId":'+ userid + ',"UserName":'+username+',"PassWord":null,"Nickname":null,"Email":null,"Phone":null,"Token":'+token+',"HeaderPic":null,"Form":0,"FormKey":0}';
// 	var json='{"UserId":'+"1" + ',"UserName":'+"hujiulong"+',"PassWord":null,"Nickname":null,"Email":null,"Phone":null,"Token":'+"tokenxyz"+',"HeaderPic":null,"Form":0,"FormKey":0}';
		 unityFrame.window.CallUnity3d_RecieveUserId(json);
	}
	//打开户型搜索面板
	
	function showSearchPanel(){
		searchDig.open();
	}
	//加载户型
	function loadHourse(src){
		//alert('开始调用加载户型了' +src) ;
		searchDig.close();
		unityFrame.window.imageUploaded(src);
	}
</script>


<script type='text/javascript' src='https://ssl-webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/jquery.min.js'></script>
		<script type="text/javascript">
		<!--
		var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js";
		if (document.location.protocol == 'https:')
			unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
		document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
		-->
		</script>
		<script type="text/javascript">
 			var config = {
			    width: '100%',  
                height: '100%',  
				params: { enableDebugging:"0" }
	
			};
			config.params["disableContextMenu"] = true;
			var u = new UnityObject2(config);
			
			jQuery(function() {

				var $missingScreen = jQuery("#unityPlayer").find(".missing");
				var $brokenScreen = jQuery("#unityPlayer").find(".broken");
				$missingScreen.hide();
				$brokenScreen.hide();

				u.observeProgress(function (progress) {
					switch(progress.pluginStatus) {
						case "broken":
							$brokenScreen.find("a").click(function (e) {
								e.stopPropagation();
								e.preventDefault();
								u.installPlugin();
								return false;
							});
							$brokenScreen.show();
						break;
						case "missing":
							$missingScreen.find("a").click(function (e) {
								e.stopPropagation();
								e.preventDefault();
								u.installPlugin();
								return false;
							});
							$missingScreen.show();
						break;
						case "installed":
							$missingScreen.remove();
						break;
						case "first":
						break;
					}
				});
				u.initPlugin(jQuery("#unityPlayer")[0], "Out.unity3d");
			});
 
	function getDesignId(){
		return "1001";
	}
			function CallUnity3d_RecieveUserId(json)
			{
				u.getUnity().SendMessage("U3d","CallUnity3d_RecieveUserId",json);
			}
		 
	 
		</script>
		<style type="text/css">
		<!--
		        *{ margin:0; padding:0;}  
          
        html, body {  
            width: 100%;  
            height: 100%;  
            overflow: hidden;  
            padding: 0px;  
            margin: 0px;  
            border: none;  
            text-align:none;  
        }  
        body {  
            font-family: Helvetica, Verdana, Arial, sans-serif;  
            background-color: white;  
            color: black;  
            text-align: center;  
            height: 100%;  
            width: 100%;  
              
        }  
        a:link, a:visited {  
            color: #000;  
        }  
        a:active, a:hover {  
            color: #666;  
        }  
        p.header {  
            font-size: small;  
        }  
        p.header span {  
            font-weight: bold;  
        }  
        p.footer {  
            font-size: x-small;  
        }  
        div.content {  
             border-width: 0px;  
            border-color: none;  
            margin: auto;  
            width: 100%;  
            height: 100%;  
            border-color: none  
        }  
        div.broken,  
        div.missing {  
            margin: auto;  
            position: relative;  
            top: 50%;  
            width: 193px;  
        }  
        div.broken a,  
        div.missing a {  
            margin: auto;  
            position: relative;  
            top: -31px;  
        }  
        div.broken img,  
        div.missing img {  
            border-width: 0px;  
        }  
        div.broken {  
            display: none;  
        }  
        div#unityPlayer {  
            cursor: default;  
            height: 100%;  
            width: 100%;  
            border-color:none;  
		-->
		</style>
</head>
<body>
		<div id="uploadPanel" style="display:none;margin-left: 48%;position:absolute; width: 300px;padding: 10px;height: 220px; margin-top: 200px;background-color: #D1D2DA">
			  <a href="javascript:closeUploadPanelAndShowUnity()"   style="margin-top: 10px; margin-right: 10px;display: block;float: right;">X</a>
			  <label  style="display: block;padding-top: 20px;">请选择文件</label>
			  <input id="lmfile" name="files" type="file" style="display: block" />
			  <input type="button"  value="提交" onclick="uploadImage('lmfile')" style="display: block; margin-top: 10px; "/>
			  <img id="image_preview" src="" alt="" style="    margin-top: 15px;">
		</div>

		<div id="searchPanel">
			
			
			<div class="nav-tool">
			        <label>户型搜索</label>
                    <div class="i-search">
                        <input id="keyword" type="text" class="i-search-input" placeholder="请输入关键词搜索">
                        <button type="submit" class="btn-search">
                            <span class="icon icon-serch-black"></span>
                        </button>
                    </div> 
                </div>
                <div>
				<ul id="searchList" class="img-list-base" style="height: 387px;">
				</ul>
			   <div class="demo customBootstrap" style="float: left;">
           	 		<ul id="pageiter" class="pagination"></ul>
       		   </div>
			  </div>
		</div>
		
		<div class="content">
			<div id="unityPlayer">
				<div class="missing">
					<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
						<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
					</a>
				</div>
			</div>
		</div>
 </body>
</html>